#include<func.h>
//pthread_join等待子进程
void* pthread_func(void *p)
{
    printf("I am child thread %ld\n",(long)p);
    return NULL;
}
//创建两个子线程,0号线程打印我是线程0,1号线程打印我线程1
int main()
{
    pthread_t pthid[2];
    long i;
    int ret;
    for(i=0;i<2;i++)
    {
        ret=pthread_create(pthid+i,NULL,pthread_func,(void*)i);
        THREAD_ERR_CHECK(ret,"pthread_creat");
    }
    ret=pthread_join(pthid[0],NULL);//等待子线程
    THREAD_ERR_CHECK(ret,"pthread_join1");
    ret=pthread_join(pthid[1],NULL);//等待子线程
    THREAD_ERR_CHECK(ret,"pthread_join2");
    printf("I am main thread\n");
    return 0;
}